

import itertools
from typing import List


def largestTimeFromDigits(arr: List[int]) -> str:
    ans = -1
    for h1,h2,m1,m2 in  itertools.permutations(arr):
        hours = 10 * h1 + h2
        mins = 10 * m1 +m2
        time = 60 * hours + mins
        if 0 <= hours < 24 and 0 <= mins < 60 and time > ans:
            ans =time
    return "{:02}:{:02}".format(*divmod(ans,60)) if ans >= 0 else ""